package com.cal.utms.action.maintenance;

import java.util.List;

import com.cal.utms.dto.maintenance.DealerDto;
import com.cal.utms.model.maintenance.MasterDataModel;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.ActionSupport;

public class DealerAction extends ActionSupport implements ModelDriven<DealerDto> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private DealerDto dealerDto = new DealerDto();
	private MasterDataModel dataModel = new MasterDataModel();

	private String dealers;

	public String saveDealers() {
		dataModel.saveDealers(dealerDto, dealers);
		return Action.SUCCESS;
	}

	public String getDealres() {
		List<DealerDto> dealerDtos = dataModel.getDealers();
		if (dealerDtos != null) {
			dealerDto.setDealerDtos(dealerDtos);
			dealerDto.setSuccess(true);
			dealerDto.setResultMsg("SUCCESS");
		} else {
			dealerDto.setSuccess(false);
			dealerDto.setResultMsg("No Records");
		}
		return Action.SUCCESS;
	}

	public DealerDto getDealerDto() {
		return dealerDto;
	}

	public void setDealerDto(DealerDto dealerDto) {
		this.dealerDto = dealerDto;
	}

	@Override
	public DealerDto getModel() {
		return dealerDto;
	}

	public String getDealers() {
		return dealers;
	}

	public void setDealers(String dealers) {
		this.dealers = dealers;
	}

}
